//================================================
/*

Turn Off the Lights
The entire page will be fading to dark, so you can watch the video as if you were in the cinema.
Copyright (C) 2011 Stefan vd
www.stefanvd.net

This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2
of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.


To view a copy of this license, visit http://creativecommons.org/licenses/GPL/2.0/

*/
//================================================

function $(id) { return document.getElementById(id); }
/*
/////////// API for Website Developer
// id way
var websiteapi = $('dont-turn-off-the-lights');
if(websiteapi){$('dont-turn-off-the-lights').style.zIndex = 1000;$('dont-turn-off-the-lights').style.visibility = 'visible';$('dont-turn-off-the-lights').style.position = 'relative';}

// class way
div = document.getElementsByTagName('*'); 
for(var i = 0; i < div.length; i++ )
{if(div[i].className == ('dont-turn-off-the-lights')) {div[i].style.zIndex = 1000;div[i].style.visibility = 'visible';div[i].style.position = 'relative';}}

/////////// HTML5 video
video = document.getElementsByTagName('video');
for(var i = 0; i < video.length; i++) {
// other file then "mp3" then run this code
if (video[i].currentSrc.lastIndexOf(".mp3")==-1) {video[i].style.zIndex = 1000;video[i].style.visibility = 'visible';video[i].style.position = 'relative';}
else {}// do nothing
}
// YouTube video OK
// MAC & PC & LINUX
var movieplayer = $('movie_player');
if(movieplayer){$('movie_player').style.zIndex = 1000;$('movie_player').style.visibility = 'visible';$('movie_player').style.position = 'relative';}

// Youtube Channel, fixed show video
var userplaylist = $('user_playlist_navigator');
if(userplaylist)$('user_playlist_navigator').style.zIndex = 'auto';

var playnav = $('playnav-body');
if(playnav)$('playnav-body').style.zIndex = 'auto';

var player = $('playnav-player');
if(player)$('playnav-player').style.zIndex = 1000;

// HTML5
var html5player = $('html5-player');
if(html5player){$('html5-player').style.zIndex = 1001;$('html5-player').style.visibility = 'visible';$('html5-player').style.position = 'relative';}

var youtubehtml5 = $('video-player');
if(youtubehtml5){$('video-player').style.zIndex = 1001;$('video-player').style.visibility = 'visible';$('video-player').style.position = 'relative';}

div = document.getElementsByTagName('div'); 
for(var i = 0; i < div.length; i++ ) 
{if(div[i].className == ('video-controls')) {div[i].style.zIndex = 1001;div[i].style.visibility = 'visible';}}

// YouTube Channel gadget, Google app
var user_fullwidth_gadget = $('user_fullwidth_gadget');
if(user_fullwidth_gadget){$('user_fullwidth_gadget').style.zIndex = 1000;$('user_fullwidth_gadget').style.visibility = 'visible';$('user_fullwidth_gadget').style.position = 'relative';}

// YouTube Embed video style iframe
iframe = document.getElementsByTagName('iframe'); 
for(var i = 0; i < iframe.length; i++ )
{if(iframe[i].className == ('youtube-player')) {iframe[i].style.zIndex = 1000;iframe[i].style.visibility = 'visible';iframe[i].style.position = 'relative';}}

// YouTube bottom bar (visible off)
// new YouTube playlist (my feeds) 
var playlistbar = $('playlist-bar');
if(playlistbar){$('playlist-bar').style.zIndex = 'auto';}

var quicklist = $('quicklist');
if(quicklist){$('quicklist').style.zIndex = 'auto';}

*/
/////////// Option page settings

// Show YouTube Suggestions
chrome.extension.sendRequest({comando:'totlrequest'},function(response){
var suggestions = response.suggestions;
if(suggestions == 'true'){
var watchsidebar = $('watch-sidebar');
if(watchsidebar){$('watch-sidebar').style.zIndex = 'auto';}

div = document.getElementsByTagName('div'); 
for(var i = 0; i < div.length; i++ ) 
{if(div[i].className == ('watch-module-body')) {div[i].style.background = 'none';div[i].style.zIndex = 1001;div[i].style.position = 'relative';}}
}
/*
// Show YouTube playlist
var playlist = response.playlist;
if(playlist == 'true'){
// new YouTube playlist (my feeds) 
var quicklist = $('quicklist');
if(quicklist){$('quicklist').style.zIndex = 1001;}

var playlistbar = $('playlist-bar');
if(playlistbar){$('playlist-bar').style.zIndex = 1001;}
}

// Show video title
var videoheadline = response.videoheadline;
if(videoheadline == 'true'){
var eowtitle = $('eow-title');
if(eowtitle){$('eow-title').style.color = 'white';$('eow-title').style.zIndex = 1001;$('eow-title').style.position = 'relative';}
}
// Show all Flash
function R(w){
try{
var d =w.document,j,i,t,T,N,b,r=1,C;
for(j=0;t=['object','embed','applet','iframe'][j];++j)
{
T=d.getElementsByTagName(t);
for(i=T.length-1;(i+1)&&(N=T[i]);--i)
if(j!=3||!R((C=N.contentWindow)?C:N.contentDocument.defaultView))
{

N.style.position = 'relative';
N.style.zIndex = 1000;

}
}
}catch(E){r = 0}
return r
}

var flash = response.flash;
if(flash == 'true'){
intelligentvideodetection();

R(self);
var i,x;
for(i=0;x=frames[i];++i)R(x)
}

// Show YouTube Channel name
var head = response.head ;
if(head == 'true'){
var watchheadline = $('watch-headline-user-info');
if(watchheadline){$('watch-headline-user-info').style.zIndex = 1000;$('watch-headline-user-info').style.position = 'relative';}

var watchchannel = $('watch-channel-discoverbox');
if(watchchannel){$('watch-channel-discoverbox').style.zIndex = 1000;$('watch-channel-discoverbox').style.position = 'relative';$('watch-channel-discoverbox').style.background = 'white';}

var watchmore = $('watch-more-from-user');
if(watchmore){$('watch-more-from-user').style.zIndex = 1000;$('watch-more-from-user').style.position = 'relative';$('watch-more-from-user').style.background = 'none';}

var watchuser = $('watch-userbanner');
if(watchuser){$('watch-userbanner').style.zIndex = 1000;$('watch-userbanner').style.position = 'relative';$('watch-userbanner').style.background = 'white';}

span = document.getElementsByTagName('span'); 
for(var i = 0; i < span.length; i++ ) 
{if(span[i].className == ('watch-expander-head yt-uix-expander-head yt-rounded') ) {span[i].style.background = 'white';}}
}

// Show Infobar
var infobar = response.infobar;
if(infobar == 'true'){
var watchinfo = $('watch-info');
if(watchinfo){$('watch-info').style.zIndex = 1000;$('watch-info').style.position = 'relative';$('watch-info').style.background = 'white';}

div = document.getElementsByTagName('div'); 
for(var i = 0; i < div.length; i++ )
{if(div[i].className == ('watch-expander-head yt-uix-expander-head yt-rounded')) {div[i].style.zIndex = 1000;div[i].style.visibility = 'visible';div[i].style.position = 'relative';div[i].style.background = 'white'; }}
}

// Show like and unlike buttons
var likebutton = response.likebutton;
if(likebutton == 'true'){
var watchlike = $('watch-like');
if(watchlike){$('watch-like').style.zIndex = 1000;$('watch-like').style.position = 'relative';}

var watchunlike = $('watch-unlike');
if(watchunlike){$('watch-unlike').style.zIndex = 1000;$('watch-unlike').style.position = 'relative';}
}

// Show share buttons
var sharebutton = response.sharebutton;
if(sharebutton == 'true'){
var watchplaylistsbutton = $('watch-playlists-button');
if(watchplaylistsbutton){$('watch-playlists-button').style.zIndex = 1000;$('watch-playlists-button').style.position = 'relative';}

var watchshare = $('watch-share');
if(watchshare){$('watch-share').style.zIndex = 1000;$('watch-share').style.position = 'relative';}

var watchactionsareacontainer = $('watch-actions-area-container');
if(watchactionsareacontainer){$('watch-actions-area-container').style.zIndex = 1000;$('watch-actions-area-container').style.position = 'relative';}

var watchactionsarea = $('watch-actions-area');
if(watchactionsarea){$('watch-actions-area').style.zIndex = 1000;$('watch-actions-area').style.position = 'relative';$('watch-actions-area').style.background = 'white';}
}

// Watch view count
var viewcount = response.viewcount;
if(viewcount == 'true'){
span = document.getElementsByTagName('span'); 
for(var i = 0; i < span.length; i++ )
{if(span[i].className == ('watch-view-count')) {span[i].style.color = 'white';span[i].style.zIndex = 1001;span[i].style.position = 'relative';}}
}

*/
});

/*

/////////// Turn Off the Lights -> on

// New intelligent video detection --------------
function intelligentvideodetection() {
if (window.location.href.match('http://www.youtube.com')){} // flash detection off for youtube.com
else {
a = document.getElementsByTagName('*');for(var i = 0; i < a.length; i++ ) {a[i].style.zIndex = 'auto';}
}
}
//-----------------------------------------------
*/
/*
// Google Buzz
// Google Profile page
if (window.location.href.match('https://profiles.google.com'))
{
iframe = document.getElementsByTagName('iframe'); 
for(var i = 0; i < iframe.length; i++ )
{if(iframe[i].className == ('Mh')) {iframe[i].style.zIndex = 1000;iframe[i].style.visibility = 'visible';iframe[i].style.position = 'relative';}}
}

// Feedly
else if (window.location.href.match('http://www.feedly.com'))
{
div = document.getElementsByTagName('div'); 
for(var i = 0; i < div.length; i++ ) 
{if(div[i].className == ('inlineFrame')) {div[i].style.zIndex = 'auto';}}

embed = document.getElementsByTagName('embed'); 
for(var i = 0; i < embed.length; i++ ) 
{embed[i].style.zIndex = 1000;embed[i].style.position = 'relative';}
}

// Google Video OK

// Google Movies Trailer
else if (window.location.href.match('http://www.google.com/movies'))
{
var myytplayer = $('myytplayer');
if(myytplayer){$('myytplayer').style.zIndex = 1000;$('myytplayer').style.position = 'relative';}
}

// Break OK
else if (window.location.href.match(/http:\/\/(www\.break\.com\/.*\/.*)/i))
{
intelligentvideodetection();

var defaultDiv = $('defaultDiv');
if(defaultDiv){$('defaultDiv').style.zIndex = 1000;$('defaultDiv').style.position = 'relative';}
}

// MegaVideo OK
else if (window.location.href.match(/http:\/\/(.*megavideo\.com\/.*|www\.megavideo\.com\/.*\/.*)/i))
{
var mvplayer = $('mvplayer');
if(mvplayer){$('mvplayer').style.zIndex = 1000;$('mvplayer').style.visibility = 'visible';$('mvplayer').style.position = 'relative';}
}

// YouKu.com OK

// Yahoo video OK
else if (window.location.href.match(/http:\/\/(video\.yahoo\.com\/watch\/.*\/.*|video\.yahoo\.com\/network\/.*|movies\.yahoo\.com\/movie\/.*\/video\/.*|movies\.yahoo\.com\/movie\/.*\/trailer|movies\.yahoo\.com\/movie\/.*\/video)/i))
{
var fop = $('fopObj');
if(fop){$('fopObj').style.zIndex = 1000;$('fopObj').style.visibility = 'visible';$('fopObj').style.position = 'relative';}

var video1 = $('video1');
if(video1){$('video1').style.zIndex = 1000;$('video1').style.visibility = 'visible';$('video1').style.position = 'relative';}
}

// vevo OK
else if (window.location.href.match(/http:\/\/(www\.vevo\.com\/.*\/.*)/i))
{
var thePlayer = $('thePlayer');
if(thePlayer){$('thePlayer').style.zIndex = 1000;$('thePlayer').style.visibility = 'visible';$('thePlayer').style.position = 'relative';}
}

// Vimeo, fixed show video
else if (window.location.href.match(/http:\/\/(.*vimeo\.com\/.*|.*vimeo\.com\/.*\/b\/.*|.*vimeo\.com\/.*\/w\/.*)/i))
{
intelligentvideodetection();

// fix bug video website
video = document.getElementsByTagName('video'); 
for(var i = 0; i < video.length; i++ ) 
{if(video[i]) {video[i].style.zIndex = 1000;video[i].style.visibility = 'visible';video[i].style.position = 'relative';video[i].style.margin = '0px';video[i].style.top = '0%';video[i].style.left = '0px';}}
div = document.getElementsByTagName('div');
for(var i = 0; i < div.length; i++ )
{if(div[i].className == ('an')) {div[i].style.zIndex = 1001;}}
div = document.getElementsByTagName('div');
for(var i = 0; i < div.length; i++ )
{if(div[i].className == ('c')) {div[i].style.zIndex = 1001;}}
//---
cuturl = document.URL.substring(7);
var parts = cuturl.split('/');
vimeoplayer = 'vimeo_player_' + parts[1];
var vmplayer = $(vimeoplayer);
if(vmplayer){$(vimeoplayer).style.zIndex = 1001;$(vimeoplayer).style.visibility = 'visible';$(vimeoplayer).style.position = 'relative';}

div = document.getElementsByTagName('div'); 
for(var i = 0; i < div.length; i++ ) 
{if(div[i].className == ('vimeo_holder')) {div[i].style.zIndex = 1001;div[i].style.position = 'relative';}}
}

// Justin.tv, fixed show video
else if (window.location.href.match(/http:\/\/(.*justin\.tv\/.*|.*justin\.tv\/.*\/b\/.*|.*justin\.tv\/.*\/w\/.*)/i))
{
intelligentvideodetection();

var live_frontpage_player_flash = $('live_frontpage_player_flash');
if(live_frontpage_player_flash){$('live_frontpage_player_flash').style.zIndex = 1001;$('live_frontpage_player_flash').style.visibility = 'visible';$('live_frontpage_player_flash').style.position = 'relative';}

var standard_holder = $('standard_holder');
if(standard_holder){$('standard_holder').style.zIndex = 1001;$('standard_holder').style.visibility = 'visible';$('standard_holder').style.position = 'relative';}

var live_site_player_container = $('live_site_player_container');
if(live_site_player_container){$('live_site_player_container').style.zIndex = 'auto';}

var live_site_player_flash = $('live_site_player_flash');
if(live_site_player_flash){$('live_site_player_flash').style.zIndex = 1000;$('live_site_player_flash').style.visibility = 'visible';$('live_site_player_flash').style.position = 'relative';}
}

// LiveLeak, fixed show video
else if (window.location.href.match(/http:\/\/(liveleak\.com\/view\?.*|www\.liveleak\.com\/view\?.*)/i))
{
intelligentvideodetection();

var player = $('player');
if(player){$('player').style.zIndex = 1001;$('player').style.visibility = 'visible';$('player').style.position = 'relative';}
}

// Metacafe, fixed show video
else if (window.location.href.match(/http:\/\/(www\.metacafe\.com\/watch\/.*|www\.metacafe\.com\/w\/.*)/i))
{
intelligentvideodetection();

var ItemContainer = $('ItemContainer');
if(ItemContainer)$('ItemContainer').style.zIndex = 1000;
}

// Dailymotion, fixed show video
else if (window.location.href.match(/http:\/\/(.*\.dailymotion\.com\/video\/.*|.*\.dailymotion\.com\/.*\/video\/.*)/i))
{
intelligentvideodetection();

div = document.getElementsByTagName('div'); 
for(var i = 0; i < div.length; i++ ) 
{if(div[i].className == ('dmpi_video_playerv4 span-8')) {div[i].style.zIndex = 1000;div[i].style.position = 'relative';}}

// HTML5 video
div = document.getElementsByTagName('div'); 
for(var i = 0; i < div.length; i++ ) 
{if(div[i].className == ('controls_container')) {div[i].style.zIndex = 1000;}}
}

// Veoh, fixed show video
else if (window.location.href.match(/http:\/\/(www\.veoh\.com\/.*\/.*)/i))
{
var MediaPlayerWrapper = $('MediaPlayerWrapper');
if(MediaPlayerWrapper){$('MediaPlayerWrapper').style.zIndex = 1001;$('MediaPlayerWrapper').style.visibility = 'visible';$('MediaPlayerWrapper').style.position = 'relative';}

var can = $('can');
if(can){$('can').style.zIndex = 1001;$('can').style.visibility = 'visible';$('can').style.position = 'relative';}
}

// CBS, fixed show video
else if (window.location.href.match(/http:\/\/(www\.cbs\.com\/.*\/.*)/i))
{
var flashcontent = $('flashcontent');
if(flashcontent){$('flashcontent').style.zIndex = 1000;$('flashcontent').style.visibility = 'visible';$('flashcontent').style.position = 'relative';}
}

// Rutube, fixed show video
else if (window.location.href.match('http://rutube.ru'))
{
intelligentvideodetection();

var player = $('player');
if(player){$('player').style.zIndex = 'auto';}

var nav = $('nav');
if(nav){$('nav').style.zIndex = 0;}

var header = $('header');
if(header){$('header').style.zIndex = 0;}

var main_menu = $('main_menu');
if(main_menu){$('main_menu').style.zIndex = 0;$('main_menu').style.position = 'relative';}

var pid = $('pid');
if(pid){$('pid').style.zIndex = 1000;}

var playerID = $('playerID');
if(playerID){$('playerID').style.zIndex = 1000;$('playerID').style.visibility = 'visible';$('playerID').style.position = 'relative';}

var VideoWall = $('VideoWall');
if(VideoWall){$('VideoWall').style.zIndex = 1000;$('VideoWall').style.visibility = 'visible';$('VideoWall').style.position = 'relative';}
}

// MyVideo, fixed show video
else if (window.location.href.match(/http:\/\/(.*myvideo\.de\/.*|www\.myvideo\.de\/.*\/.*)/i))
{
var home_player_swf = $('home_player_swf');
if(home_player_swf){$('home_player_swf').style.zIndex = 1000;$('home_player_swf').style.visibility = 'visible';$('home_player_swf').style.position = 'relative';}

var video_player_swf = $('video_player_swf');
if(video_player_swf){$('video_player_swf').style.zIndex = 1000;$('video_player_swf').style.visibility = 'visible';$('video_player_swf').style.position = 'relative';}

var specials_video_player_swf = $('specials_video_player_swf');
if(specials_video_player_swf){$('specials_video_player_swf').style.zIndex = 1000;$('specials_video_player_swf').style.visibility = 'visible';$('specials_video_player_swf').style.position = 'relative';}

var series_player_swf = $('series_player_swf');
if(series_player_swf){$('series_player_swf').style.zIndex = 1000;$('series_player_swf').style.visibility = 'visible';$('series_player_swf').style.position = 'relative';}

var player_container = $('player_container');
if(player_container){$('player_container').style.zIndex = 1000;$('player_container').style.position = 'relative';}

var group_player_box = $('group_player_box');
if(group_player_box){$('group_player_box').style.zIndex = 1000;$('group_player_box').style.position = 'relative';}
}

// hulu, fixed show video
else if (window.location.href.match(/http:\/\/(www\.hulu\.com\/watch.*|www\.hulu\.com\/w\/.*|hulu\.com\/watch.*|hulu\.com\/w\/.*)/i))
{
var playercontainer = $('player-container');
if(playercontainer){$('player-container').style.zIndex = 1000;$('player-container').style.position = 'relative';}
}

// comedycentral, fixed show video
else if((document.URL.indexOf('http://www.comedycentral.com') == 0)||(document.URL.indexOf('http://comedycentral.com') == 0))
{
var videoPlayer = $('videoPlayer');
if(videoPlayer){$('videoPlayer').style.zIndex = 1000;$('videoPlayer').style.position = 'relative';}
}

// atom.com, fixed show video
else if((document.URL.indexOf('http://www.atom.com') == 0))
{
var FederatedPlayer = $('FederatedPlayer');
if(FederatedPlayer){$('FederatedPlayer').style.zIndex = 1000;$('FederatedPlayer').style.position = 'relative';}

div = document.getElementsByTagName('div'); 
for(var i = 0; i < div.length; i++ ) 
{if(div[i].className == ('siteheader')) {div[i].style.zIndex = 0;}}
}

// southparkstudios, fixed show video
else if (window.location.href.match(/http:\/\/(www\.southparkstudios\.com\/.*\/.*)/i))
{
var mtvnPlayer = $('mtvnPlayer');
if(mtvnPlayer){$('mtvnPlayer').style.zIndex = 1000;$('mtvnPlayer').style.position = 'relative';}

var videoPlayer = $('videoPlayer');
if(videoPlayer){$('videoPlayer').style.zIndex = 1000;$('videoPlayer').style.position = 'relative';}

var clipsplayer = $('clips_player');
if(clipsplayer){$('clips_player').style.zIndex = 1000;$('clips_player').style.position = 'relative';}
}

// colbertnation, fixed show video
else if((document.URL.indexOf('http://www.colbertnation.com') == 0)||(document.URL.indexOf('http://colbertnation.com') == 0))
{
intelligentvideodetection();

var video_player = $('video_player');
if(video_player){$('video_player').style.zIndex = 1000;$('video_player').style.position = 'relative';}

var videoPlayer = $('videoPlayer');
if(videoPlayer){$('videoPlayer').style.zIndex = 1000;$('videoPlayer').style.position = 'relative';}

div = document.getElementsByTagName('div'); 
for(var i = 0; i < div.length; i++ ) 
{if(div[i].className == ('video_list')) {div[i].style.zIndex = 1000;}}
}

// thedailyshow, fixed show video
else if((document.URL.indexOf('http://www.thedailyshow.com') == 0)||(document.URL.indexOf('http://www.thedailyshow.com') == 0))
{
intelligentvideodetection();

var video_player = $('video_player');
if(video_player){$('video_player').style.zIndex = 1000;$('video_player').style.position = 'relative';}

var videoPlayer = $('videoPlayer');
if(videoPlayer){$('videoPlayer').style.zIndex = 1000;$('videoPlayer').style.position = 'relative';}

div = document.getElementsByTagName('div'); 
for(var i = 0; i < div.length; i++ ) 
{if(div[i].className == ('video_list')) {div[i].style.zIndex = 1000;}} 
}

// spike, fixed show video
else if (window.location.href.match(/http:\/\/(www\.spike\.com\/video\/.*)/i))
{
var FlashID1 = $('FlashID1');
if(FlashID1){$('FlashID1').style.zIndex = 1000;$('FlashID1').style.position = 'relative';}

var video_player = $('video_player');
if(video_player){$('video_player').style.zIndex = 1000;$('video_player').style.position = 'relative';}
}

// blip.tv, fixed show video
else if (window.location.href.match(/http:\/\/(blip\.tv\/file\/.*|.*\.blip\.tv\/file\/.*)/i))
{
var video_player = $('video_player');
if(video_player){$('video_player').style.zIndex = 1000;$('video_player').style.position = 'relative';}
}

// zshare.net, fixed show video
else if (window.location.href.match(/http:\/\/(www\.zshare\.net\/.*\/.*)/i))
{
var video_wrapper = $('video_wrapper');
if(video_wrapper){$('video_wrapper').style.zIndex = 1000;$('video_wrapper').style.position = 'relative';}

iframe = document.getElementsByTagName('iframe'); 
for(var i = 0; i < iframe.length; i++ ) 
{iframe[i].style.zIndex = 1000;iframe[i].style.position = 'relative';}
}

// crunchyroll.com, fixed show video
else if (window.location.href.match(/http:\/\/(www\.crunchyroll\.com\/.*\/.*)/i))
{
var template_body = $('template_body');
if(template_body){$('template_body').style.zIndex = 'auto';}

var template_container = $('template_container');
if(template_container){$('template_container').style.zIndex = 'auto';}

var showmedia_video_player = $('showmedia_video_player');
if(showmedia_video_player){$('showmedia_video_player').style.zIndex = 1000;$('showmedia_video_player').style.position = 'relative';}
}

// muzu.tv, fixed show video
else if (window.location.href.match(/http:\/\/(.*muzu\.tv\/.*|www\.muzu\.tv\/.*\/.*)/i))
{
var muzuplayer = $('muzuplayer');
if(muzuplayer){$('muzuplayer').style.zIndex = 1000;$('muzuplayer').style.position = 'relative';$('muzuplayer').style.visibility = 'visible';}
}

// ustream.tv, fixed show video
else if (window.location.href.match(/http:\/\/(www\.ustream\.tv\/recorded\/.*|www\.ustream\.tv\/channel\/.*|www\.ustream\.tv\/.*)/i))
{
var v2 = $('v2');
if(v2){$('v2').style.zIndex = 1000;$('v2').style.visibility = 'visible';$('v2').style.position = 'relative';}

iframe = document.getElementsByTagName('iframe'); 
for(var i = 0; i < iframe.length; i++ ) 
{if(iframe[i].className == ('socialstream') ) {iframe[i].style.zIndex = 'auto';}}
}

// blip.fm, fixed show video
else if (window.location.href.match(/http:\/\/(www\.blip\.fm\/.*\/.*)/i))
{
var youtubePlayerBackdrop = $('youtubePlayerBackdrop');
if(youtubePlayerBackdrop){$('youtubePlayerBackdrop').style.zIndex = 1000;$('youtubePlayerBackdrop').style.position = 'relative';}

var youtubePlayerBackdrop = $('display');
if(youtubePlayerBackdrop){$('display').style.zIndex = 1000;}
}

// fora.tv, fixed show video
else if((document.URL.indexOf('http://fora.tv') == 0))
{
var FORA_Player_5 = $('FORA_Player_5');
if(FORA_Player_5){$('FORA_Player_5').style.zIndex = 1000;$('FORA_Player_5').style.position = 'relative';}

div = document.getElementsByTagName('div'); 
for(var i = 0; i < div.length; i++ ) 
{if(div[i].className == ('player_top') ) {div[i].style.zIndex = 1000;div[i].style.position = 'relative';}}
}

// livestream.com, fixed show video
else if (window.location.href.match(/http:\/\/(www\.livestream\.com\/.*)/i))
{
// nav bar
var header = $('header');
if(header){$('header').style.zIndex = 1000;}

var navchannels= $('nav-channels');
if(navchannels){$('nav-channels').style.zIndex = 1000;}

// video player
var channelplayerbox = $('channel-player-box');
if(channelplayerbox){$('channel-player-box').style.zIndex = 'auto';}

var channelplayer = $('channel-player');
if(channelplayer){$('channel-player').style.zIndex = 'auto';}

var gridplayer = $('grid-player');
if(gridplayer){$('grid-player').style.zIndex = 1000;}

var livestreamPlayer = $('livestreamPlayer');
if(livestreamPlayer){$('livestreamPlayer').style.zIndex = 1000;}
}

// Social
// Netlog, fixed show video
else if (window.location.href.match(/http:\/\/(.*netlog\.com\/.*|.*netlog\.com\/.*\/b\/.*|.*netlog\.com\/.*\/w\/.*)/i))
{
var video_player= $('video_player');
if(video_player){$('video_player').style.zIndex = 1001;$('video_player').style.visibility = 'visible';$('video_player').style.position = 'relative';}
}

// Facebook, fixed show video
else if (window.location.href.match(/http:\/\/(.*facebook\.com\/.*|.*facebook\.com\/.*\/b\/.*|.*facebook\.com\/.*\/w\/.*)/i))
{
div = document.getElementsByTagName('div'); 
for(var i = 0; i < div.length; i++ ) 
{
if(div[i].className == ('__fbswf')) {div[i].style.zIndex = 1001;div[i].style.visibility = 'visible';div[i].style.position = 'relative';}
}

// video inside post
div = document.getElementsByTagName('div'); 
for(var i = 0; i < div.length; i++ ) 
{
if(div[i].className == ('uiVideoThumb uiVideoThumbLoading ')) {div[i].style.zIndex = 1000;}
}

// video profile post
div = document.getElementsByTagName('div'); 
for(var i = 0; i < div.length; i++ ) 
{
if(div[i].className == ('uiVideoThumb UIImageBlock_Image UIImageBlock_MED_Image uiVideoThumbLoading ') ) {div[i].style.zIndex = 1000;}
}

// video inside profile video
var videoplayer = $('player');
if(videoplayer){$('player').style.zIndex = 1000;$('player').style.visibility = 'visible';$('player').style.position = 'relative';}

// video inside post
div = document.getElementsByTagName('div'); 
for(var i = 0; i < div.length; i++ ) 
{
if(div[i].className == ('UIMediaItem')) {div[i].style.zIndex = 1000;div[i].style.position = 'relative';}
}

// video post page
div = document.getElementsByTagName('div'); 
for(var i = 0; i < div.length; i++ ) 
{
if(div[i].className == ('UIImageBlock clearfix exploded')) {div[i].style.zIndex = 1000;div[i].style.position = 'relative';}
}
}

// MySpace, fixed show video
else if (window.location.href.match('http://www.myspace.com'))
{
var msVideoPlayer = $('msVideoPlayer');
if(msVideoPlayer){$('msVideoPlayer').style.zIndex = 1001;$('msVideoPlayer').style.visibility = 'visible';$('msVideoPlayer').style.position = 'relative';}
}

// vkontakte.ru (ru social network) fixed show video
else if (window.location.href.match(/http:\/\/(.*vkontakte\.ru\/.*|.*vkontakte\.ru\/.*\/b\/.*|.*vkontakte\.ru\/.*\/w\/.*)/i))
{
var video_player = $('video_player');
if(video_player){$('video_player').style.visibility = 'visible';$('video_player').style.zIndex = 1000;$('video_player').style.position = 'relative';}

var flash_player_container = $('flash_player_container');
if(flash_player_container){$('flash_player_container').style.zIndex = 'auto';}
}

// flickr video
else if (window.location.href.match(/http:\/\/(www\.flickr\.com\/photos\/.*|flic\.kr\/.*)/i))
{
var photo = $('photo');
if(photo){$('photo').style.zIndex = 1000;}

var candy_nav_button_bar = $('candy_nav_button_bar');
if(candy_nav_button_bar){$('candy_nav_button_bar').style.zIndex = 0;$('candy_nav_button_bar').style.position = 'relative';}

var candy_search_button_bar = $('candy_search_button_bar');
if(candy_search_button_bar){$('candy_search_button_bar').style.zIndex = 0;$('candy_search_button_bar').style.position = 'relative';}

img = document.getElementsByTagName('img'); 
for(var i = 0; i < img.length; i++ ) 
{if(img[i].className == ('pc_img') ) {img[i].style.zIndex = 1000;img[i].style.position = 'relative';}}

var ajax_pagination = $('ajax_pagination');
if(ajax_pagination){$('ajax_pagination').style.zIndex = 1000;$('ajax_pagination').style.position = 'relative';}

img = document.getElementsByTagName('img'); 
for(var i = 0; i < img.length; i++ ) 
{if(img[i].className == ('reflect')) {img[i].style.zIndex = 1000;img[i].style.position = 'relative';}}
}

// Deviantart picture
else if (window.location.href.match(/http:\/\/(.*\.deviantart\.com\/art\/.*|.*\.deviantart\.com\/gallery\/.*|.*\.deviantart\.com\/#\/.*|fav\.me\/.*|.*\.deviantart\.com|.*\.deviantart\.com\/gallery|.*\.deviantart\.com\/.*\/.*\.jpg|.*\.deviantart\.com\/.*\/.*\.gif|.*\.deviantart\.net\/.*\/.*\.jpg|.*\.deviantart\.net\/.*\/.*\.gif)/i))
{
div = document.getElementsByTagName('div'); 
for(var i = 0; i < div.length; i++ ) 
{
if(div[i].className == ('browse2-results')) {div[i].style.zIndex = 1000;div[i].style.position = 'relative';}
}
var gmiPreviewStream= $('gmi-PreviewStream');
if(gmiPreviewStream){$('gmi-PreviewStream').style.zIndex = 1000;$('gmi-PreviewStream').style.position = 'relative';}

var browse2stream = $('browse2-stream');
if(browse2stream){$('browse2-stream').style.zIndex = 1000;$('browse2-stream').style.position = 'relative';}

var prevnextlinks= $('prev-next-links');
if(prevnextlinks){$('prev-next-links').style.zIndex = 1000;$('prev-next-links').style.position = 'relative';}
}

/////////// Work

// Google Images
else if (window.location.href.match(/http:\/\/(.*google\..*\/images\?.*)/i))
{
var ires = $('ires');
if(ires){$('ires').style.visibility = 'visible';$('ires').style.zIndex = 1000;$('ires').style.position = 'relative';}

var tphdr = $('tphdr');
if(tphdr){$('tphdr').style.zIndex = 999;}
}

// Google Picasa
else if (window.location.href.match(/https:\/\/(picasaweb\.google\.com.*\/.*\/.*#.*|picasaweb\.google\.com.*\/lh\/photo\/.*|picasaweb\.google\.com.*\/.*\/.*)/i))
{
var lhid_content = $('lhid_content');
if(lhid_content){$('lhid_content').style.visibility = 'visible';$('lhid_content').style.zIndex = 1000;$('lhid_content').style.position = 'relative';}
}

// Google Reader
else if ((window.location.href.match('http://www.google.com/reader'))||(window.location.href.match('https://www.google.com/reader')))
{
// entries
var entries = $('entries');
if(entries){$('entries').style.zIndex = 'auto';}

embed = document.getElementsByTagName('embed'); 
for(var i = 0; i < embed.length; i++ ) 
{embed[i].style.zIndex = 1000;embed[i].style.position = 'relative';}
}

/////////// Tech news

// CNET, fixed show video
else if (window.location.href.match(/http:\/\/(.*cnet\.com\/.*|.*cnet\.com\/.*\/b\/.*|.*cnet\.com\/.*\/w\/.*)/i))
{
var universalVideoWrapper1= $('universalVideoWrapper1');
if(universalVideoWrapper1){$('universalVideoWrapper1').style.zIndex = 1000;}

div = document.getElementsByTagName('div'); 
for(var i = 0; i < div.length; i++ ) 
{if(div[i].id == ('rb_mtx') ) {div[i].style.zIndex = 'auto';}
}

var player2 = $('player2');
if(player2){$('player2').style.visibility = 'visible';$('player2').style.zIndex = 1000;$('player2').style.position = 'relative';}

var cnettvPlayer = $('cnettvPlayer');
if(cnettvPlayer){$('cnettvPlayer').style.visibility = 'visible';$('cnettvPlayer').style.zIndex = 1000;$('cnettvPlayer').style.position = 'relative';}
}

// ZDNET, fixed show video OK
// Crunchgear, fixed show video OK
// Techcrunch, fixed show video OK
// Gizmodo, fixed show video

// Mashable, fixed show video OK
else if (window.location.href.match(/http:\/\/(.*mashable\.com\/.*|.*mashable\.com\/.*\/b\/.*|.*mashable\.com\/.*\/w\/.*)/i))
{
object = document.getElementsByTagName('object'); 
for(var i = 0; i < object.length; i++ ) 
{if(object[i]) {object[i].style.zIndex = 1000;object[i].style.position = 'relative';object[i].style.visibility = 'visible';}}
}

// PC world, fixed show video
else if (window.location.href.match(/http:\/\/(.*pcworld\.com\/.*|.*pcworld\.com\/.*\/b\/.*|.*pcworld\.com\/.*\/w\/.*)/i))
{
var videoPlayer = $('videoPlayer');
if(videoPlayer){$('videoPlayer').style.visibility = 'visible';$('videoPlayer').style.zIndex = 1000;$('videoPlayer').style.position = 'relative';}

var jwPlaya = $('jwPlaya');
if(jwPlaya){$('jwPlaya').style.visibility = 'visible';$('jwPlaya').style.zIndex = 1000;$('jwPlaya').style.position = 'relative';}
}

// WIRED, fixed show video
else if (window.location.href.match(/http:\/\/(.*wired\.com\/.*|.*wired\.com\/.*\/b\/.*|.*wired\.com\/.*\/w\/.*)/i))
{
var myPlayer = $('myPlayer');
if(myPlayer){$('myPlayer').style.visibility = 'visible';$('myPlayer').style.zIndex = 1000;$('myPlayer').style.position = 'relative';}
}

// Engadget, fixed show video
else if (window.location.href.match(/http:\/\/(.*engadget\.com\/.*|.*engadget\.com\/.*\/b\/.*|.*engadget\.com\/.*\/w\/.*)/i))
{
var video_port = $('video_port');
if(video_port){$('video_port').style.visibility = 'visible';$('video_port').style.zIndex = 1000;$('video_port').style.position = 'relative';}
}

// Cnn.com, fixed show video
else if (window.location.href.match(/http:\/\/(.*cnn\.com\/video\/.*)/i))
{
var cvp1 = $('cvp_1');
if(cvp1){$('cvp_1').style.visibility = 'visible';$('cvp_1').style.zIndex = 1000;$('cvp_1').style.position = 'relative';}
}

// Reuters, fixed show video
else if (window.location.href.match(/http:\/\/(.*reuters\.com\/.*)/i))
{
intelligentvideodetection();

var rvplayer = $('rvplayer');
if(rvplayer){$('rvplayer').style.visibility = 'visible';$('rvplayer').style.zIndex = 1000;$('rvplayer').style.position = 'relative';}
}

// espn.go.com, fixed show video
else if (window.location.href.match(/http:\/\/(espn\.go\.com\/video\/clip.*|espn\.go\.com\/.*\/story.*)/i))
{
// hide ads
div = document.getElementsByTagName('div'); 
for(var i = 0; i < div.length; i++ ) {if(div[i].className == ('span-6 ad pencil top') ) {div[i].style.zIndex = 0;}
}

var topstories = $('top-stories');
if(topstories){$('top-stories').style.visibility = 'visible';$('top-stories').style.zIndex = 1000;$('top-stories').style.position = 'relative';}

var header = $('header');
if(header){$('header').style.zIndex = 0;}

var videoPlayer = $('videoPlayer');
if(videoPlayer){$('videoPlayer').style.visibility = 'visible';$('videoPlayer').style.zIndex = 1000;$('videoPlayer').style.position = 'relative';}

var player = $('player');
if(player){$('player').style.visibility = 'visible';$('player').style.zIndex = 1000;$('player').style.position = 'relative';}
}

// nba.com, fixed show video
else if (window.location.href.match(/http:\/\/(.*nba\.com\/.*|.*nba\.com\/.*\/b\/.*|.*nba\.com\/.*\/w\/.*)/i))
{
var cvp_player = $('cvp_player');
if(cvp_player){$('cvp_player').style.zIndex = 1000;$('cvp_player').style.position = 'relative';$('cvp_player').style.visibility = 'visible';}

var medium_rectangle_external_ad = $('medium_rectangle_external_ad');
if(medium_rectangle_external_ad){$('medium_rectangle_external_ad').style.zIndex = 0;$('medium_rectangle_external_ad').style.position = 'relative';$('medium_rectangle_external_ad').style.visibility = 'hidden';}
}

// Apple.com, fixed show video
else if (window.location.href.match(/http:\/\/(.*apple\.com\/.*|.*apple\.com\/.*\/b\/.*|.*apple\.com\/.*\/w\/.*)/i))
{
intelligentvideodetection();

// div moviePanel
var moviePanel = $('moviePanel');
if(moviePanel){$('moviePanel').style.zIndex = 1000;}

// class object bar
object = document.getElementsByTagName('object'); 
for(var i = 0; i < object.length; i++ ) 
{if(object[i].className == (' quicktime')) {object[i].style.zIndex = 1000;}}

// Media controls bar
div = document.getElementsByTagName('div'); 
for(var i = 0; i < div.length; i++ ) 
{if(div[i].className == ('ACMediaControls')) {div[i].style.zIndex = 1000;}}

// Video setting
div = document.getElementsByTagName('div'); 
for(var i = 0; i < div.length; i++ ) 
{if(div[i].className == ('settingsControls settingsControls-sizes')) {div[i].style.zIndex = 1000;}}
  
div = document.getElementsByTagName('div'); 
for(var i = 0; i < div.length; i++ ) 
{if(div[i].className == (' ACMediaSettingsMenu-selected')) {div[i].style.zIndex = 1000;}}

// End image
div = document.getElementsByTagName('div'); 
for(var i = 0; i < div.length; i++ ) 
{if(div[i].className == ('media')) {div[i].style.zIndex = 1000;}}
}

// tsn.ca fixed show video
else if (window.location.href.match(/http:\/\/(.*tsn\.ca\/.*|.*tsn\.ca\/.*\/b\/.*|.*tsn\.ca\/.*\/w\/.*)/i))
{
var __FlashPlayer = $('__FlashPlayer');
if(__FlashPlayer){$('__FlashPlayer').style.zIndex = 1000;$('__FlashPlayer').style.position = 'relative';}
}

// free-tv-video-online.me fixed show video
else if (window.location.href.match('http://www.free-tv-video-online.me'))
{
var hmovie = $('hmovie');
if(hmovie){$('hmovie').style.zIndex = 1000;$('hmovie').style.position = 'relative';}
}

// ted.com fixed show video
else if (window.location.href.match(/http:\/\/(.*ted\.com\/.*|.*ted\.com\/.*\/b\/.*|.*ted\.com\/.*\/w\/.*)/i))
{
var streamingPlayerSWF = $('streamingPlayerSWF');
if(streamingPlayerSWF){$('streamingPlayerSWF').style.zIndex = 1000;$('streamingPlayerSWF').style.position = 'relative';}
}

// wisevid.com fixed show video
else if (window.location.href.match(/http:\/\/(.*wisevid\.com\/.*|.*wisevid\.com\/.*\/b\/.*|.*wisevid\.com\/.*\/w\/.*)/i))
{
var player = $('player');
if(player){$('player').style.zIndex = 1000;$('player').style.position = 'relative';}
}

// imdb.com fixed show video
else if (window.location.href.match(/http:\/\/(.*imdb\.com\/.*|.*imdb\.com\/.*\/b\/.*|.*imdb\.com\/.*\/w\/.*)/i))
{
var videoplayercontainer = $('video-player-container');
if(videoplayercontainer){$('video-player-container').style.zIndex = 1000;$('video-player-container').style.position = 'relative';}
}

// fun fix canvas focus on jigzone.com
else if (window.location.href.match(/http:\/\/(.*jigzone\.com\/.*|.*jigzone\.com\/.*\/b\/.*|.*jigzone\.com\/.*\/w\/.*)/i))
{
var Z = $('Z');
if(Z){$('Z').style.zIndex = 1000;}
}

// tvcatchup.com fixed show video
else if (window.location.href.match(/http:\/\/(.*tvcatchup\.com\/.*|.*tvcatchup\.com\/.*\/b\/.*|.*tvcatchup\.com\/.*\/w\/.*)/i))
{
var InSkinBaseContainer = $('InSkinBaseContainer_myInSkin1');
if(InSkinBaseContainer){$('InSkinBaseContainer_myInSkin1').style.zIndex = 1000;}

var InSkinContentContainer = $('InSkinContentContainer_myInSkin1');
if(InSkinContentContainer){$('InSkinContentContainer_myInSkin1').style.zIndex = 1000;}

// object
var myInSkin1 = $('myInSkin1');
if(myInSkin1){$('myInSkin1').style.zIndex = 1000;$('myInSkin1').style.position = 'relative';}
}

*/

//Windows Media Player
//Silverlight
//Quicktime
// -> object,embed,applet,iframe
// -> turn on the flash detection

///////////

	// Black div on
	var blackon = document.getElementById('stefanvdlightareoff1');

	function reader() {
	var totlreaderbar = $('totlreaderbar');
	var totlreaderbarscript = $('totlreaderbarscript');
	var totlreaderbarstyle = $('totlreaderbarstyle');
	if(totlreaderbar) {document.body.removeChild(totlreaderbar);}
	if(totlreaderbarscript) {document.body.removeChild(totlreaderbarscript);}
	if(totlreaderbarstyle) {document.body.removeChild(totlreaderbarstyle);}
	
	// YouTube video title (set back to default)
	var eowtitle = $('eow-title');
	if(eowtitle){$('eow-title').style.color = '#333';$('eow-title').style.zIndex = 'auto';$('eow-title').style.position = 'relative';}
	// YouTube video view count (set back to default)
	var eowtitle = $('eow-title');
	if(eowtitle){$('eow-title').style.color = '#333';$('eow-title').style.zIndex = 'auto';$('eow-title').style.position = 'relative';}
	span = document.getElementsByTagName('span'); 
	for(var i = 0; i < span.length; i++ )
	{if(span[i].className == ('watch-view-count')) {span[i].style.color = '#333';span[i].style.zIndex = 'auto';span[i].style.position = 'relative';}}
	}
	
	function removenewframe() {
	var stefanvdlightareoff1 = $('stefanvdlightareoff1');
	var stefanvdlightareoff2 = $('stefanvdlightareoff2');
	var stefanvdlightareoff3 = $('stefanvdlightareoff3');
	var stefanvdlightareoff4 = $('stefanvdlightareoff4');
	if(stefanvdlightareoff1) {document.body.removeChild(stefanvdlightareoff1);}
	if(stefanvdlightareoff2) {document.body.removeChild(stefanvdlightareoff2);}
	if(stefanvdlightareoff3) {document.body.removeChild(stefanvdlightareoff3);}
	if(stefanvdlightareoff4) {document.body.removeChild(stefanvdlightareoff4);}
	
	var totlmousespotlightscript = document.getElementById("totlmousespotlightscript");
	if(totlmousespotlightscript){document.body.removeChild(totlmousespotlightscript);document.onmousemove=null;window.onresize=null;document.onmousewheel=null;};	
	var totlmousespotlightstyle = $('totlmousespotlightstyle');
	if(totlmousespotlightstyle) {document.body.removeChild(totlmousespotlightstyle);}
	}
	
chrome.extension.sendRequest({comando:'totlrequest'},function(response){
	if(blackon) {
	var mousespotlight = response.mousespotlight;
	if(!mousespotlight)mousespotlight = 'false'; // default mousespotlight false
	if(mousespotlight == 'true'){
		// fade out effect
		var fadeout = response.fadeout;
		if(!fadeout)fadeout = 'true'; // default fadeout false
		if(fadeout == 'true'){ReducingFinished = false;fader('hide');}
		else{removenewframe();}
	reader();
	}
	else {
		// fade out effect
		var fadeout = response.fadeout;
		if(!fadeout)fadeout = 'true'; // default fadeout false
		if(fadeout == 'true'){ReducingFinished = false;fader('hide');}
		else{document.body.removeChild(blackon);}
		}
	reader();
	}
	else {
		var interval = response.interval;		
		if(!interval)interval = 80;		
		var color = response.colors;
		if(color)color = '#' + response.colors;
		else color = '#000000';
		default_opacity = interval;
		
	    var mousespotlight = response.mousespotlight;
	    if(!mousespotlight)mousespotlight = 'false'; // default mousespotlight false
	    if(mousespotlight == 'true'){
	    // Design
	    var totlmousespotlightstyle = document.createElement('style');
	    totlmousespotlightstyle.setAttribute('id','totlmousespotlightstyle');
	    totlmousespotlightstyle.innerHTML = '.stefanvdlightareoff{position:fixed; top:0px; left:0px; width:100%; height:100%; z-index:999; background:'+color+'; opacity:0;}';
	    document.body.appendChild(totlmousespotlightstyle);

	    // script
	    var totlmousespotlightscript = document.createElement('script'); 
	    totlmousespotlightscript.setAttribute('id','totlmousespotlightscript');
	    totlmousespotlightscript.innerHTML = 'var tabwitdh = document.body.clientWidth;var tabheight = window.innerHeight+15;function OnResizeDocument(){tabwitdh = document.body.clientWidth;tabheight = window.innerHeight+15;offX = "50%";offY = 30;off2X = 30;off2Y = -15;off3X = -tabwitdh-15;off3Y = -15;off4X = "50%";off4Y = -tabheight;follow();}var divName1 = "stefanvdlightareoff1";var divName2 = "stefanvdlightareoff2";var divName3 = "stefanvdlightareoff3";var divName4 = "stefanvdlightareoff4";var offX = "50%";var offY = 30;var off2X = 30;var off2Y = -15;var off3X = -tabwitdh-15;var off3Y = -15;var off4X = "50%";var off4Y = -tabheight;function mouseX(evt) {if (!evt) evt = window.event; if (evt.clientX) return evt.clientX; else return 0;}function mouseY(evt) {if (!evt) evt = window.event; if (evt.clientY) return evt.clientY; else return 0;}function follow(evt) {if (document.getElementById) {var obj1 = document.getElementById(divName1).style; obj1.visibility = "visible";var obj2 = document.getElementById(divName2).style; obj2.visibility = "visible";var obj3 = document.getElementById(divName3).style; obj3.visibility = "visible";var obj4 = document.getElementById(divName4).style; obj4.visibility = "visible";obj1.left = (parseInt(mouseX(evt))+offX) + "px";obj1.top = (parseInt(mouseY(evt))+offY) + "px";obj2.left = (parseInt(mouseX(evt))+off2X) + "px";obj2.top = (parseInt(mouseY(evt))+off2Y) + "px";obj3.left = (parseInt(mouseX(evt))+off3X) + "px";obj3.top = (parseInt(mouseY(evt))+off3Y) + "px";obj4.left = (parseInt(mouseX(evt))+off4X) + "px";obj4.top = (parseInt(mouseY(evt))+off4Y) + "px";}}var mouseactiondiv = document.getElementById("totlmousespotlightscript"); if(mouseactiondiv){document.onmousemove=follow;window.onresize=OnResizeDocument;document.onmousewheel=OnResizeDocument;}';
	    document.body.appendChild(totlmousespotlightscript);

	    var newframe1 = document.createElement("div");
	    var newframe2 = document.createElement("div");
	    var newframe3 = document.createElement("div");
	    var newframe4 = document.createElement("div");
	    newframe1.setAttribute('id','stefanvdlightareoff1');
	    newframe2.setAttribute('id','stefanvdlightareoff2');
	    newframe3.setAttribute('id','stefanvdlightareoff3');
	    newframe4.setAttribute('id','stefanvdlightareoff4');
	    newframe1.setAttribute('class','stefanvdlightareoff');
	    newframe2.setAttribute('class','stefanvdlightareoff');
	    newframe3.setAttribute('class','stefanvdlightareoff');
	    newframe4.setAttribute('class','stefanvdlightareoff');
	    newframe2.style.height = '45px';
	    newframe3.style.height = '45px';
	    newframe2.style.visibility = 'hidden';
	    newframe3.style.visibility = 'hidden';
	    newframe4.style.visibility = 'hidden';
	    document.body.appendChild(newframe1);
	    document.body.appendChild(newframe2);
	    document.body.appendChild(newframe3);
	    document.body.appendChild(newframe4);

	    // fade out effect      
		var fadeout = response.fadeout;
		if(!fadeout)fadeout = 'true'; // default fadeout false
		if(fadeout == 'true'){
		newframe1.onclick = function() {fader('hide');reader();}
		newframe2.onclick = function() {fader('hide');reader();}
		newframe3.onclick = function() {fader('hide');reader();}
		newframe4.onclick = function() {fader('hide');reader();}	
		}
        else{
		newframe1.onclick = function() {removenewframe();reader();}
		newframe2.onclick = function() {removenewframe();reader();}
		newframe3.onclick = function() {removenewframe();reader();}
		newframe4.onclick = function() {removenewframe();reader();}
		}

        // fade in effect      
		var fadein = response.fadein;
		if(!fadein)fadein = 'true'; // default fadein true
		if(fadein == 'true'){fader('show');}
        else{newframe1.style.opacity = default_opacity/100;newframe2.style.opacity = default_opacity/100;newframe3.style.opacity = default_opacity/100;newframe4.style.opacity = default_opacity/100;} // no fade effect
		}
		else {
		var newdiv = document.createElement('div'); 
        newdiv.setAttribute('id','stefanvdlightareoff1');
        newdiv.setAttribute('class','stefanvdlightareoff');
		newdiv.style.width = '100%'; 
        newdiv.style.height = '100%'; 
        newdiv.style.left = 0; 
        newdiv.style.top = 0; 
        newdiv.style.position = 'fixed';
		/* if image background, load it then */
			var lightimagea = response.lightimagea;
			var lightimage = response.lightimage;
			if (lightimagea == 'true'){newdiv.style.background = "url('"+lightimage+"')";}
			else {newdiv.style.background = color;}
		/*-------------*/    
        newdiv.style.opacity = 0;
        newdiv.style.zIndex = 999;
		
        document.body.appendChild(newdiv);
		
	    // fade out effect      
		var fadeout = response.fadeout;
		if(!fadeout)fadeout = 'true'; // default fadeout false
		if(fadeout == 'true'){newdiv.onclick = function() {fader('hide');reader();}}
        else{newdiv.onclick = function() {document.body.removeChild(newdiv);reader();}}

        // fade in effect      
		var fadein = response.fadein;
		if(!fadein)fadein = 'true'; // default fadein true
		if(fadein == 'true'){fader('show');}
        else{newdiv.style.opacity = default_opacity/100;} // no fade effect		
}

/////////// Turn Off the Lights reader slider

// Show always option
var readera = response.readera;
if(readera == 'true'){
// script
var totlreaderbarscript = document.createElement('script'); 
totlreaderbarscript.setAttribute('id','totlreaderbarscript');
totlreaderbarscript.innerHTML = 'function $(id){return document.getElementById(id);}function showValue(newValue){$("totlgammaVal").value = newValue;$("totlrange").value = newValue;div = document.getElementsByTagName("div"); for(var i = 0; i < div.length; i++ ){if(div[i].className == ("stefanvdlightareoff")) {div[i].style.opacity = (newValue/100);}}}function toggle_small() {var totlreader = document.getElementById("__totl-tidbit-box");var totlreadermin = document.getElementById("__totl-min");if ( totlreader.style.width != "24px" ) {totlreader.style.width = "24px";totlreader.style.height = "24px";totlreadermin.style.opacity = "0";}else {totlreader.style.width = "";totlreader.style.height = "";totlreadermin.style.opacity = "100";}}';
document.body.appendChild(totlreaderbarscript);

// Design
var totlreaderbarstyle = document.createElement('style');
totlreaderbarstyle.setAttribute('id','totlreaderbarstyle');
totlreaderbarstyle.innerHTML = '@-webkit-keyframes "slide-up"{from{bottom:-100%;-webkit-animation-timing-function:ease-out}to{bottom:0;}}#totlreaderbar{ position:fixed !important; bottom: 5px !important; right: 5px !important; z-Index: 2147483647 !important; }#__totl-tidbit-box, #__totl-wrapper, #__totl-box-info, #__totl-box-tidbits table { float: none; border-collapse: collapse; border-spacing: 0; margin: 0px; padding: 0px; border: 0px solid transparent; background: transparent; }#__totl-tidbit-box, #__totl-wrapper, #__totl-box-info, #__totl-box-tidbits table td { vertical-align: middle; margin: 0px; border: 0px solid transparent; background-color: transparent; padding: 0px; }#__totl-tidbit-box, #__totl-wrapper, #__totl-box-info, #__totl-box-tidbits table tr:hover {background-color: transparent;}#__totl-tidbit-box, #__totl-wrapper, #__totl-box-info, #__totl-box-tidbits img { margin: 0px; padding: 0px; border: 0px; }.__totl-tidbit { display: inline !important; background-color: #ffffdd; color: #000000; text-decoration: inherit; }#__totl-tidbit-box { display: block; position: fixed; z-index: 2147483647; opacity: 0.95; top: auto; bottom: 0; left: auto; right: 0; width: 178px; min-width: 0; max-width: 200px; min-height: 0; max-height: 80px; margin: 4px; padding: 0; overflow: hidden; background-color: #ccc !important; border: 1px solid transparent; -webkit-border-radius: 3px; }#__totl-min { width: 14px !important; height: 14px !important; position: absolute; right: 5px; background-repeat: no-repeat; background-position: right top; cursor: pointer !important; background-image: url('+chrome.extension.getURL("/images/minimize.png")+'); }#__totl-min:hover { width: 14px !important; height: 14px !important; position: absolute; right: 5px; background-repeat: no-repeat; background-position: right top; cursor: pointer !important; background-image: url('+chrome.extension.getURL("/images/minimize_on.png")+'); }#__totl-wrapper { padding: 4px 0 2px !important; -webkit-border-radius: 3px; }#__totl-tidbit-box, #__totl-tidbit-box div, #__totl-tidbit-box span { float: none; color: #eee !important; font: menu; font-size: 9pt; white-space: normal; letter-spacing: normal; word-spacing: normal; line-height: 11pt; text-align: left; text-decoration: none; cursor: default; }#__totl-tidbit-box, #__totl-tidbit-box div { background-color: #111; -webkit-animation-name: slide-up; -webkit-animation-duration: 0.75s; }#__totl-tidbit-box div, #__totl-tidbit-box span { width: auto; -webkit-user-select: none; margin: 0; padding: 0; border: none; }#__totl-box-info { display: block; min-height: 18px; margin: 0 10px 0 4px !important; padding: 0 0 2px 20px !important; background-repeat: no-repeat; background-position: left top; }.__totl-box-title, .__totl-box-title span { font-weight: bold !important; }#__totl-box-tidbits { display: -webkit-box; -webkit-box-orient: vertical; }.__totl-box-tidbit, .__totl-box-msg { display: -webkit-box; padding: 4px 4px 0px 4px !important; margin: 0 !important; border-top: 1px solid #363636 !important; border-bottom: 1px solid #000 !important; background: -webkit-gradient(linear,left top,left bottom,from(#111),to(#000)); }.__totl-box-tidbit { cursor: pointer !important; }#__totl-tidbit-box .__totl-box-tidbit:hover, #__totl-tidbit-box .__totl-box-tidbit:hover span, #__totl-tidbit-box .__totl-box-tidbit-selected, #__totl-tidbit-box .__totl-box-tidbit-selected span { color: #ffff88 !important; cursor: pointer !important; }.__totl-box-tidbit b span, .__totl-box-tidbit em span { font-weight: bold !important; }.__totl-nowrap { white-space: nowrap !important; }/* Slider */#totlgammaVal { width: 26px; height: 20px; margin-left: 3px; margin-right: 3px; padding: 0px; border: 0px; background-color: transparent; color: white; font-size: 12px; font-family: Verdana, Geneva, Tahoma, sans-serif; }#totlrange{-webkit-appearance: slider-horizontal; padding: initial; border: initial; margin: 2px; position: relative !important;}';
document.body.appendChild(totlreaderbarstyle);

// small or large style
var readerlargestyle = response.readerlargestyle;
if(!readerlargestyle)readerlargestyle = 'true'; // default large style
if(readerlargestyle == 'true'){
// Object large
var totlreaderbar = document.createElement('div'); 
totlreaderbar.setAttribute('id','totlreaderbar');
totlreaderbar.innerHTML = '<div id="__totl-tidbit-box"><div id="__totl-wrapper"><img id="__totl-min" alt="" src="'+chrome.extension.getURL("/images/minimize.png")+'" onclick="toggle_small()"><div id="__totl-box-info" class="__totl-box-title" style="background-image: url('+chrome.extension.getURL("/icons/icon16.png")+');" onclick="toggle_small()"><span class="__totl-nowrap">Turn Off the Lights</span></div><div id="__totl-box-tidbits"><div class="__totl-box-msg"><table><tr><td><input type="range" id="totlrange" min="0" max="100" step="1" value="0" onchange="showValue(this.value)"/></td><td><input id="totlgammaVal" maxlength="3" size="3" type="text" value="0" onchange="showValue(this.value)"/></td></tr></table></div></div></div></div>';
}
else{
// Object small
var totlreaderbar = document.createElement('div'); 
totlreaderbar.setAttribute('id','totlreaderbar');
totlreaderbar.innerHTML = '<div id="__totl-tidbit-box" style="width: 24px; height: 24px;"><div id="__totl-wrapper"><img id="__totl-min" alt="" src="'+chrome.extension.getURL("/images/minimize.png")+'" onclick="toggle_small()" style="opacity: 0;"><div id="__totl-box-info" class="__totl-box-title" style="background-image: url('+chrome.extension.getURL("/icons/icon16.png")+');" onclick="toggle_small()"><span class="__totl-nowrap">Turn Off the Lights</span></div><div id="__totl-box-tidbits"><div class="__totl-box-msg"><table><tr><td><input type="range" id="totlrange" min="0" max="100" step="1" value="0" onchange="showValue(this.value)"/></td><td><input id="totlgammaVal" maxlength="3" size="3" type="text" value="0" onchange="showValue(this.value)"/></td></tr></table></div></div></div></div>';
}
document.body.appendChild(totlreaderbar);

// settings reader slider
	var interval = response.interval;
	if(!interval)interval = 80;
	default_opacity = interval;
	$('totlgammaVal').value = interval;
	$('totlrange').value = interval;
} //End option always		
	}

});

///////////

// Fade engine
//  Variable for the fade in and out effect
var opacity = 0;

var ReducingFinished = true;
var OpacityLevelIncrement = 10;   //  Percentage value: 1-100
var FadeDelayMS = 60;             //  Milliseconds

//  Function determines whether we show or hide the item referenced by ElementID
function fader(ActionToTake)
{
  DIVElementById = $('stefanvdlightareoff1');
  if (ActionToTake == 'hide')
  { opacity = default_opacity; reduceOpacity(); }
  else if (ActionToTake == 'show')
  { increaseOpacity(); }
}

//  Makes div increase
function increaseOpacity()
{
  //  If opacity level is less than default_opacity, we can still increase the opacity
  if ((opacity < default_opacity) && (ReducingFinished == true))
  {
	if ((opacity > (default_opacity-10)) && (ReducingFinished == true)){
    ReducingFinished = true;
    opacity  += (default_opacity - opacity);
    DIVElementById.style.opacity = opacity/100;
	setTimeout('increaseOpacity()', FadeDelayMS);
	}
	else {
    ReducingFinished = true;
    opacity  += OpacityLevelIncrement;
    DIVElementById.style.opacity = opacity/100;
    setTimeout('increaseOpacity()', FadeDelayMS);
	}
  }
  else
  {
    ReducingFinished = false;
  }
//control opacity for all <div>
div = document.getElementsByTagName('div'); 
for(var i = 0; i < div.length; i++ ) 
{if(div[i].className == ('stefanvdlightareoff')) {div[i].style.opacity = opacity/100;}}
}

//  Makes div reduce
function reduceOpacity() 
{
  //  If opacity level is greater than 0, we can still reduce the opacity
  if ((opacity > 0) && (ReducingFinished == false))
  {
    ReducingFinished = false;
    opacity  -= OpacityLevelIncrement;
    DIVElementById.style.opacity = opacity/100;
    setTimeout('reduceOpacity()', FadeDelayMS);
  }
  else
  {
    ReducingFinished = true;

    //  When finished, make sure the DIVElementById is set to remove element
    if (DIVElementById.style.opacity = '0')
    {document.body.removeChild(DIVElementById);removenewframe();}
  }
//control opacity for all <div>
div = document.getElementsByTagName('div'); 
for(var i = 0; i < div.length; i++ ) 
{if(div[i].className == ('stefanvdlightareoff')) {div[i].style.opacity = opacity/100;}}
}
